﻿using Core.Tools.IOC;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UI.Application.Share.Config;
using UI.Application.Share.Reactor;

namespace UI.Application.Config.Services
{
    /// <summary>
    /// PID参数提供者
    /// </summary>
    [ExposedService(Lifttime.Singleton,typeof(IPidProvider))]
    class PidProvider : IPidProvider
    {
        public PidParameter Parameter { get; set; } = new PidParameter();

        public PID GetHeatPID(ReactorName reactorName)
        {
            PID pid = new PID();
            switch (reactorName)
            {
                case ReactorName.None:
                    break;
                case ReactorName.Reactor1:
                    pid.P = Parameter.Reactor1Heat_KP;
                    pid.I = Parameter.Reactor1Heat_KI;
                    pid.D = Parameter.Reactor1Heat_KD;
                    break;
                case ReactorName.Reactor2:
                    pid.P = Parameter.Reactor2Heat_KP;
                    pid.I = Parameter.Reactor2Heat_KI;
                    pid.D = Parameter.Reactor2Heat_KD;
                    break;
                default:
                    break;
            }
            return pid;
        }

        public PID GetPeltierPID(ReactorName reactorName)
        {
            PID pid = new PID();
            switch (reactorName)
            {
                case ReactorName.None:
                    break;
                case ReactorName.Reactor1:
                    pid.P = Parameter.Reactor1Peltier_KP;
                    pid.I = Parameter.Reactor1Peltier_KI;
                    pid.D = Parameter.Reactor1Peltier_KD;
                    break;
                case ReactorName.Reactor2:
                    pid.P = Parameter.Reactor2Peltier_KP;
                    pid.I = Parameter.Reactor2Peltier_KI;
                    pid.D = Parameter.Reactor2Peltier_KD;
                    break;
                default:
                    break;
            }
            return pid;
        }
    }
}
